package com.example.photographWatermark

import android.app.Activity
import android.content.Intent
import android.graphics.BitmapFactory
import android.os.Bundle
import android.util.Log
import androidx.appcompat.app.AppCompatActivity
import com.example.photographWatermark.camera2.CameraActivity
import kotlinx.android.synthetic.main.activity_photo.*


class MainActivity : Activity() {


    companion object {
        public var imagePath: String? = null
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_photo)
        val imgPath = intent.getStringExtra("camera")
//        val name = intent.getStringExtra("name")
//        val address = intent.getStringExtra("address")
//        val time = intent.getStringExtra("time")
        val bm = BitmapFactory.decodeFile(imgPath)
        Log.d("===========onCreate","${ PhotographWatermarkPlugin.address}")
        Log.d("===========onCreate","${ PhotographWatermarkPlugin.name}")
        Log.d("===========onCreate","${ PhotographWatermarkPlugin.time}")
        image_idcard.setImageBitmap(bm)
        restart_btn.setOnClickListener {
            val intent = Intent(this@MainActivity, CameraActivity::class.java)
            intent.putExtra("name", PhotographWatermarkPlugin.name)
            intent.putExtra("address", PhotographWatermarkPlugin.address)
            intent.putExtra("time",PhotographWatermarkPlugin.time)
            startActivity(intent)
            finish()
        }
        use_btn.setOnClickListener {
            val intent = Intent()
            intent.putExtra("imagePath", imgPath)
            setResult(1, intent)
            imagePath = imgPath
            finish()
        }

    }


}